package com.dianban.service.impl;


import com.dianban.dao.WxUserDao;
import com.dianban.entity.*;
import com.dianban.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 用户业务实现层
 *
 */
@Service
@Transactional(readOnly = true)
public class WxUserServiceImpl implements WxUserService {

    @Autowired
    private WxUserDao wxUserDao;

    @Override
    public WxUser findByOpenId(String openId){
        WxUser wxUser = wxUserDao.findByOpenId(openId);
        return wxUser;
    }

    @Override
    @Transactional(readOnly = false)
    public int insert(WxUser wxUser) {
        wxUser.setCreatetime(System.currentTimeMillis()/1000);
        return wxUserDao.insert(wxUser);
    }

    @Override
    public WxUser findBySmallOpenId(String smallOpenId) {
        WxUser wxUser = wxUserDao.findBySmallOpenId(smallOpenId);
        return wxUser;
    }

}
